package com.jiang.daily.Q3340;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/03/14 22:11
 */
class Solution {
    public boolean isBalanced(String num) {
        int odd = 0;
        int even = 0;
        for (int i = 0; i < num.length(); i++) {
            if (i % 2 == 0) {
                even += Integer.parseInt(String.valueOf(num.charAt(i)));
            } else {
                // 把一个字符转换为 int 类型
                odd += Integer.parseInt(String.valueOf(num.charAt(i)));
            }
        }
        return even == odd;
    }
}
